﻿Ext.define("Lia.view.Editor", {
	extend : "Ext.form.Panel",
	requires : [ "Ext.form.FieldSet", "Ext.field.Select" ],
	id : 'EditorCar',
	alias : "widget.editorview",
	config : {
		scrollable : 'vertical',
		items : [ {
			xtype : "toolbar",
			docked : "top",
			title : "Edit Car",
			items : [ {
				xtype : "button",
				ui : "back",
				text : "Volver",
				itemId : "backButton"
			}, {
				xtype : "spacer"
			}, {
				xtype : "button",
				ui : "action",
				text : "Grabar",
				itemId : "saveButton"
			} ]
		}, {
			xtype : "toolbar",
			docked : "bottom",
			items : [ {
				xtype : "button",
				iconCls : "trash",
				iconMask : true,
				itemId : "deleteButton"
			} ]
		}, {
			xtype : "fieldset",
			items : [

			{
				xtype : 'textfield',
				name : 'vin',
				label : 'Modelo',
				required : true
			}, {
				xtype : 'selectfield',
				label : 'Color',
				name : 'color',
				options : [ {
					text : 'Amarillo',
					value : 'amarillo'
				}, {
					text : 'Negro',
					value : 'negro'
				}, {
					text : 'Azul',
					value : 'azul'
				}, {
					text : 'Blanco',
					value : 'blanco'
				}, {
					text : 'Perlado',
					value : 'perlado'
				} ]
			}

			]
		} ],
		listeners : [ {
			delegate : "#backButton",
			event : "tap",
			fn : "onBackButtonTap"
		}, {
			delegate : "#saveButton",
			event : "tap",
			fn : "onSaveButtonTap"
		}, {
			delegate : "#deleteButton",
			event : "tap",
			fn : "onDeleteButtonTap"
		} ]
	},
	onSaveButtonTap : function() {
		var r=confirm("¿Desea grabar los cambios?");
		if (r==true)		  
			this.fireEvent("saveNoteCommand", this);
		
	},
	onDeleteButtonTap : function() {
		var r=confirm("¿Desea eliminar el Car?");
		if (r==true)		  
		 	this.fireEvent("deleteNoteCommand", this);

	},
	onBackButtonTap : function() 
	{		
		this.fireEvent("backToHomeCommand", this);
	}

});
